import requests
import json
from PIL import Image, ImageDraw, ImageFont
from requests.api import get
import test


# 请求一言文本数据
def getText():
    r = requests.get('https://v1.hitokoto.cn/');
    textmap = json.loads(r.text)
    print(textmap['hitokoto'], end='')
    if textmap['from_who'] or textmap['from_who'] == 'None':
        print('  --' + textmap['from'], end='')
        print('  作者:' + str(textmap['from_who']))
    else:
        print('  --' + textmap['from'])
    del r
    return textmap['hitokoto']


# 垂直水平居中
def getVHCentered(sizeX, sizeY, WidgetSizeX, WidgetSizeY):
    X = sizeX / 2
    Y = sizeY / 2
    Wx = WidgetSizeX / 2
    Wy = WidgetSizeY / 2

    X = X - Wx
    Y = Y - Wy
    return X, Y


# 垂直水平居中自动换行

# def getTextVHCenteredln(sizeX,sizeY,text,font):
#     fontX,fontY = font.getsize(text)
#     firstRowX,firstRowY = fontX,fontY
#     if(fontX <= sizeX and fontY <= sizeY):
#         x,y = getVHCentered(sizeX,sizeX,fontX,fontY)
#     else:
#         while(firstRowX <= sizeX and firstRowY <= sizeY):

#     return x,y

if __name__ == '__main__':
    pass
